package com.china08.yxyapi.repository.db;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import com.china08.yxyapi.entity.db.lessons.YxyLessonsTopicLessonChapter;

public interface YxyLessonsTopicLessonChapterRepository extends JpaRepository<YxyLessonsTopicLessonChapter, String> {
    // 查询课程全部已添加章节
    @Query(value = " select t1 from YxyLessonsTopicLessonChapter t1 where t1.lessonId = ?1 order by t1.orderNum asc")
    List<YxyLessonsTopicLessonChapter> findLessonChapterByLessonId(String lessonId);

    List<YxyLessonsTopicLessonChapter> findByLessonId(String lessonId);

    Integer countByLessonId(String lessonId);

    Integer countByLessonIdAndIdIn(String lessonId, List<String> chapterIds);

    @Query(value = " select max(t1.orderNum)  from YxyLessonsTopicLessonChapter t1 where t1.lessonId = ?1")
    Integer findMaxOrderNumLessonChapterByLessonId(String lessonId);

    List<YxyLessonsTopicLessonChapter> findByLessonIdOrderByOrderNum(String lessonId);

    YxyLessonsTopicLessonChapter findById(String chapterId);
}
